using System;
using System.Collections.Generic;
using System.Text;

namespace Eve.Data
{
    public enum EveObjectType : int
    {
        Faction = 5,
        Corporation = 10,
        Agent = 30,
        Region = 100,
        Constellation = 200,
        SolarSystem = 300,
        Celestial = 400,
        Station = 600,
    }
    public enum EvePropertyType : int
    {
        Type = 0,
        AgentType = 1,
        Division = 2,
        Operation = 3,
        StationType = 4,
        Graphic = 5,
        CorporateActivity = 6,
        Group = 7,
        Race = 8,
        Category = 9,
        MarketGroup = 10,
        Ancestry = 11,
        Bloodline = 12,
        AssemblyLine = 13,
        AssemblyLineType = 14,
        CharacterAttribute = 15,
        Attribute = 16,
        BlueprintType = 17,
        Career = 18,
        CareerSpeciality = 19,
        ControlTowerResourcePurpose = 20,
        Effect = 21,
        Flag = 22,
        InstallationType = 23,
        Landmark = 24,
        MetaGroup = 25,
        RAMActivity = 26,
        RAMCompletedStatus = 27,
        School = 28,
        Service = 29,
        Unit = 30,
        Universe = 31,
    }

    public abstract class EveObject
    {
        private EveObjectType objectType;
        private int id;
        internal Database db;

        public EveObjectType ObjectType
        {
            get { return objectType; }
        }
        public int Id
        {
            get { return id; }
        }

        internal EveObject(Database db, EveObjectType objectType, int id)
        {
            this.db = db;
            this.id = id;
            this.objectType = objectType;
        }

        public override bool Equals(object obj)
        {
            if (object.ReferenceEquals(obj, null)) return false;
            else if (obj.GetType() != this.GetType()) return false;
            else if (obj.GetType() != typeof(EveObject) && obj.GetType().BaseType != typeof(EveObject)) return false;
            else return id == ((EveObject)obj).id;
        }
        public override int GetHashCode()
        {
            return id;
        }
    }

    public abstract class EveProperty
    {
        private EvePropertyType propertyType;
        private int id;
        internal Database db;

        public EvePropertyType PropertyType
        {
            get { return propertyType; }
        }
        public int Id
        {
            get { return id; }
        }

        internal EveProperty(Database db, EvePropertyType propertyType, int id)
        {
            this.db = db;
            this.propertyType = propertyType;
            this.id = id;
        }

        public override bool Equals(object obj)
        {
            if (object.ReferenceEquals(obj, null)) return false;
            else if (obj.GetType() != this.GetType()) return false;
            else if (obj.GetType() != typeof(EveProperty) && obj.GetType().BaseType != typeof(EveProperty)) return false;
            else return propertyType == ((EveProperty)obj).propertyType && id == ((EveProperty)obj).id;
        }
        public override int GetHashCode()
        {
            return id;
        }
    }

    public abstract class EveAssociation<T1, T2>
    {
        private T1 from;
        private T2 to;
        internal Database db;

        protected T1 From
        {
            get { return from; }
        }
        protected T2 To
        {
            get { return to; }
        }

        internal EveAssociation(Database db, T1 from, T2 to)
        {
            this.db = db;
            this.from = from;
            this.to = to;
        }
    }
    public abstract class EveAssociation<T1, T2, T3>
    {
        private T1 from;
        private T2 to;
        private T3 index;
        internal Database db;

        protected T1 From
        {
            get { return from; }
        }
        protected T2 To
        {
            get { return to; }
        }
        protected T3 Index
        {
            get { return index; }
        }

        internal EveAssociation(Database db, T1 from, T2 to, T3 index)
        {
            this.db = db;
            this.from = from;
            this.to = to;
            this.index = index;
        }
    }
}
